package java111_2;

import java.util.Scanner;

public class Day28 {
    // https://www.nowcoder.com/questionTerminal/d1ac7f15d5dc40b39a7d6cb11a01407e
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = in.nextInt();
        while (q-- > 0) { // 注意 while 处理多个 case
            int x = in.nextInt();
            String str = x + "";
            char[] arr = str.toCharArray();
            int i = arr.length - 1;
            for(; i >= 0; i--){
                int tmp = arr[i] - '0';
                if(tmp % 2 == 0){
                    arr[i] = arr[arr.length-1];
                    arr[arr.length-1] = (char) (tmp + '0');
                    break;
                }
            }
            if(i < 0){
                System.out.println(-1);
            } else {
                System.out.println(new String(arr));
            }
        }
    }



}
